<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript" src="/${initParam.rootPath }/script/jquery.js"></script>
<link rel="stylesheet" href="/css/mycafe-main.css?1412662807000" type="text/css">
<style type="text/css">
table{
	width: 750px;
	border-collapse: collapse;
}
table td{
	padding: 5px;
}
</style>

<script type="text/javascript">
function searchGo(){
	document.searchForm.submit();
}
</script>

<h2>목록</h2>
<table id="post" border="1" align="center">
	<tr>
		<td width="65px" align="center">글번호</td>
		<td align="center">제목</td>
		<td width="100px" align="center">작성자</td>
		<td width="100px" align="center">작성일</td>
		<td width="60px" align="center">조회수</td>
	</tr>
	
	<c:forEach items="${requestScope.list }" var="board">
		<tr>
			<td>${board.no }</td>
			<td>
				<a href="/${initParam.rootPath }/reviewsboard/getPost.do?no=${board.no }&page=${requestScope.paging.currentPage }">
				${board.title }</a>
			</td>
			<td>${board.writer }</td>
			<td>${board.writeDate }</td>
			<td align="right">${board.viewcount }</td>
		</tr>
	</c:forEach>
	
</table>
<p>
<table align="center">
	<tr>
		<td>
			<c:choose>
				<c:when test="${requestScope.paging.previousPageGroup }">
					<a href="/${initParam.rootPath }/reviewsboard/search_list.do?page=${requestScope.paging.startPageOfPageGroup -1 }&searchBy=${requestScope.searchBy}&query=${requestScope.keyword}">◀</a>
				</c:when>
				<c:otherwise>
					◀
				</c:otherwise>
			</c:choose>
			<c:forEach begin="${requestScope.paging.startPageOfPageGroup }" end="${requestScope.paging.endPageOfPageGroup }" var="i">
				<c:choose>
					<c:when test="${i == requestScope.paging.currentPage }">
						${i }
					</c:when>
					<c:otherwise>
						<a href="/${initParam.rootPath }/reviewsboard/search_list.do?page=${i }&searchBy=${requestScope.searchBy}&query=${requestScope.keyword}">${i }</a>
					</c:otherwise>
				</c:choose>
			</c:forEach>
			<c:choose>
				<c:when test="${requestScope.paging.nextPageGroup }">
					<a href="/${initParam.rootPath }/reviewsboard/search_list.do?page=${requestScope.paging.endPageOfPageGroup +1 }&searchBy=${requestScope.searchBy}&query=${requestScope.keyword}">▶</a>
				</c:when>
				<c:otherwise>
					▶
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
</table>
<form action="/${initParam.rootPath }/reviewsboard/search_list.do" id="searchForm" onsubmit="searchGo();">
	<table>
		<tr>
			<td align="center">
	<select id="searchBy" name="searchBy" style="width: 100px;">
		<option value="0">제목</option>
		<option value="1">글작성자</option>
		<option value="2">제목+내용</option>
	</select>
			</td>
			<td align="center">
	<input type="text" id="query" name="query">
			</td>
			<td align="center">
	<input type="submit" value="검색">
			</td>
	</tr>
	</table>
</form>
<p align="right">
<a href="/${initParam.rootPath }/reviewsboard/list.do">목록</a>
<a href="/${initParam.rootPath }/reviewsboard/write_form.do">글쓰기</a>
</p>

